// 同意入队申请 {"序列":0}



// @ts-ignore
export async function execute(client_id, message_json) {
    let index = message_json["序列"];
    if (index === undefined || index <= 0) {
        ClientUtils.send_basic_prompt(client_id, "你还没有选择玩家");
        return;
    }

    let login_characters = G.Characters.get_current_login_characters(client_id);

    let team_data = G.TeamUtils.get_team_data(login_characters["队伍"]);
    if (team_data === undefined) {
        ClientUtils.send_basic_prompt(client_id, "队伍已不存在");
        return;
    }
    let apply_characters = team_data["申请"][index - 1];
    if (apply_characters === undefined) {
        ClientUtils.send_basic_prompt(client_id, "申请信息不存在");
        return;
    }
    let res = G.TeamUtils.add_characters_to_team(client_id, team_data["id"], apply_characters["id"]);

    if (res) {
        team_data = G.TeamUtils.get_team_data(login_characters["队伍"]);
        team_data["申请"].splice(index - 1, 1);
        let character_client_id = G.Characters.get_characters_client_id(apply_characters["id"]);
        if (character_client_id !== undefined) {
            ClientUtils.send_basic_prompt(character_client_id, "#Y队长已同意你的入队申请");
        }
        //通知客户端刷新审核列表
        ClientUtils.send_client_message(client_id, 4011, team_data["申请"]);
    }
}


